import { Byte } from '../../api/io/Byte';
import { HashMap } from '../../api/struct/HashMap';


export const enum E_CDLordTraining {
	/**等级*/
	id,
	/**需求等级*/
	reqLv,
	/**消耗道具id*/
	costItem,
	/**消耗数量*/
	costNum,
	/**部位1数值*/
	math_1,
	/**部位2数值*/
	math_2,
	/**部位3数值*/
	math_3,
	/**部位4数值*/
	math_4,
	/**部位5数值*/
	math_5,
	/**部位6数值*/
	math_6,
	/**部位7数值*/
	math_7,
	/**部位8数值*/
	math_8,
	/**部位9数值*/
	math_9,
	/**部位10数值*/
	math_10,

	/**枚举数量*/
	EnumCount
}



export class CDLordTraining{
	/**等级*/
	public id: number;
	/**需求等级*/
	public reqLv: number;
	/**消耗道具id*/
	public costItem: number;
	/**消耗数量*/
	public costNum: number;
	/**部位1数值*/
	public math_1: number;
	/**部位2数值*/
	public math_2: number;
	/**部位3数值*/
	public math_3: number;
	/**部位4数值*/
	public math_4: number;
	/**部位5数值*/
	public math_5: number;
	/**部位6数值*/
	public math_6: number;
	/**部位7数值*/
	public math_7: number;
	/**部位8数值*/
	public math_8: number;
	/**部位9数值*/
	public math_9: number;
	/**部位10数值*/
	public math_10: number;


	/**获取属性值*/
	public getAttr(idx: number): any {
		switch(idx) { 
			default: return;
			case E_CDLordTraining.id: return this.id;
			case E_CDLordTraining.reqLv: return this.reqLv;
			case E_CDLordTraining.costItem: return this.costItem;
			case E_CDLordTraining.costNum: return this.costNum;
			case E_CDLordTraining.math_1: return this.math_1;
			case E_CDLordTraining.math_2: return this.math_2;
			case E_CDLordTraining.math_3: return this.math_3;
			case E_CDLordTraining.math_4: return this.math_4;
			case E_CDLordTraining.math_5: return this.math_5;
			case E_CDLordTraining.math_6: return this.math_6;
			case E_CDLordTraining.math_7: return this.math_7;
			case E_CDLordTraining.math_8: return this.math_8;
			case E_CDLordTraining.math_9: return this.math_9;
			case E_CDLordTraining.math_10: return this.math_10;
		}
	}



	/**设置属性值*/
	public setAttr(idx: number, v: any): void {
		switch(idx) { 
			default: break;
			case E_CDLordTraining.id: this.id = v; break;
			case E_CDLordTraining.reqLv: this.reqLv = v; break;
			case E_CDLordTraining.costItem: this.costItem = v; break;
			case E_CDLordTraining.costNum: this.costNum = v; break;
			case E_CDLordTraining.math_1: this.math_1 = v; break;
			case E_CDLordTraining.math_2: this.math_2 = v; break;
			case E_CDLordTraining.math_3: this.math_3 = v; break;
			case E_CDLordTraining.math_4: this.math_4 = v; break;
			case E_CDLordTraining.math_5: this.math_5 = v; break;
			case E_CDLordTraining.math_6: this.math_6 = v; break;
			case E_CDLordTraining.math_7: this.math_7 = v; break;
			case E_CDLordTraining.math_8: this.math_8 = v; break;
			case E_CDLordTraining.math_9: this.math_9 = v; break;
			case E_CDLordTraining.math_10: this.math_10 = v; break;
		}
	}


	/**数据*/
	public static datas: HashMap<number, CDLordTraining> = new HashMap<number, CDLordTraining>();



	/**加载数据*/
	public static load(byte: Byte): void{
		const size = byte.readInt32();
		const list : CDLordTraining[] = [];
		let i :number;

		for (i = 0; i < size; i++) {
			list[i] = new CDLordTraining();
		}
		for (i = 0; i < size; i++) {
			list[i].id = byte.readInt32();
			this.datas.put(list[i].id, list[i]);
		}
		for (i = 0; i < size; i++) {
			list[i].reqLv = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costItem = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].costNum = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_1 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_2 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_3 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_4 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_5 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_6 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_7 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_8 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_9 = byte.readInt32();
		}
		for (i = 0; i < size; i++) {
			list[i].math_10 = byte.readInt32();
		}
	}


	/** 获取数据*/
	public static getData(id: number): CDLordTraining{
		return this.datas ? this.datas.get(id) : null;
	}
}
